package com.org.buildcycle2.model;

import android.graphics.Bitmap;
import android.graphics.Canvas;

// This class is for the player (Dude) image, also known as dude.png
// It returns the bitmap, x and y coords, and whether or not it has been touched
// This is the nicest code I've ever written. Normally I don't do this, I'd make it way messier
// - Sheel

public class Dude {
	private Bitmap map;
	private int x;
	private int y;
	private boolean isTouch;
	
	public Dude(Bitmap map, int x, int y){
		this.map = map;
		this.x = x;
		this.y = y;
	}
	
	public Bitmap getBitmap(){
		return map;
	}
	
	public void setBitmap(Bitmap map){
		this.map = map;
	}
	
	public int getX(){
		return x;
	}
	
	public int getY(){
		return y;
	}
	
	public void setX(int x){
		this.x = x;
	}
	
	public void setY(int y){
		this.y = y;
	}
	
	public boolean getTouch(){
		return isTouch;
	}
	
	public void setTouch(boolean isTouch){
		this.isTouch = isTouch;
	}
	
	public void draw(Canvas canvas){
		canvas.drawBitmap(map, x - (map.getWidth() / 2), y - (map.getHeight() / 2), null);
	}
	
	// deals with dragging the image
	public void handleAction(int action_X, int action_Y){
		if(action_X >= (x - map.getWidth() / 2) && (action_X <= (x + map.getWidth()/2))) {
			if(action_Y >= (y - map.getHeight() / 2) && (y <= (y + map.getHeight() / 2))) {
				setTouch(true);
			}else{
				setTouch(false);
			}
		}else{
			setTouch(false);
		}
	}
}
